#ifndef __NET_PARAM_H__
#define __NET_PARAM_H__

#include <stdint.h>
#include <stdio.h>
#include "face_result.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef enum
{
    image_type_vis = 0,
    image_type_nir,
}tsmImageType_e;

typedef enum
{
    face_box_vis = 0,
    face_box_nir,
}tsmFaceBox_e;

typedef enum
{
    ExtendSquare  = 0,
    ExtendSquareRegession,
    ExtendRectangle,
}TsmExtendMethod_e;


typedef struct
{
    void * depthmap_in;
    void * live3d_in;
    const char * outfile_name;
}tsmDebug_t;

typedef struct
{
    int16_t  sl3d_min_valid_value;  /*< min valid value ,default 0 */
    int16_t  sl3d_max_valid_value;  
}tsmRunParam;

typedef struct
{
    bool            detect_nir;
    bool            do_depthmap;
    bool            only_dispmap;  
    bool            detect_vis;
    bool            live_nir;
    bool            live_3d;
    bool            live_vis;
    bool            face_attr;
    bool            recog;
    bool            head_pose;
    tsmImageType_e  recog_img_type;
    tsmRunParam     param;
    tsmDebug_t      debug;
    bool            cover;
    bool            unmask;
}tsmRunMode_t;

typedef struct
{
    int w;
    int h;
    int bits;
    void *data;
}tsmImg_t;

typedef int (*ImgProcessFun_t)(tsmImg_t * dst, tsmImg_t * src, size_t arg);

typedef struct 
{
    void *      weight;
    int32_t     weight_size;

    void *      graph_w;
    int32_t     graph_w_size;
}tsmNetParam;

typedef struct 
{
    tsmNetParam     aitifake_nir;
    tsmNetParam     aitifake_vis;
    tsmNetParam     antifake_vis_nocrop;
    tsmNetParam     detect;
    tsmNetParam     detect_nir;
    tsmNetParam     landmark;
    tsmNetParam     live3d;
    tsmNetParam     qa;
    tsmNetParam     recog;
    tsmNetParam     xRecog;
    tsmNetParam     face_attributes;
    tsmNetParam     channel_expand;
    bool            use_vis_nir_recog;
    tsmFaceBox_e    live3d_facebox;
}tsmNetParamSet;


typedef struct 
{
    const float * k_rgb;        /* rightCameraMatrix */
    const float * k_ir;         /* leftCameraMatrix */
    const float * r_ir2rgb;     /* rotationMatrix */
    const float * t_ir2rgb;     /* translationVector */
}tsmAffineDepthMapParam;


typedef struct
{
    void    *  ptr_left_map_fxy_data;
    void    *  ptr_right_map_fxy_data;
    void    *  ptr_left_map_xy_data;
    void    *  ptr_right_map_xy_data;
    int32_t     minDisparity;               /*< default 12 */
    int32_t     sadWindowSize;              /*< default 13 */
    uint16_t    dp_p1;
    uint16_t    dp_p2;
    /*!
     * @brief do depth preprocess
     * @return 0 : not run hw_depth 
     */ 
    ImgProcessFun_t     PreDepthFun;        /*< default NULL */
    size_t              PreDepthFunArg;     /*< arg for PreDepthFun */ 
    tsmAffineDepthMapParam      affine_depthmap_param;
    int32_t                     scale1;
    int32_t                     scale2;
    float                       dist_to_tar;            /*< l:  -1 use defualt */
    float                       dist_between_cams;      /*< b:  -1 use defualt */
    float                       foucs;                  /*< f:  -1 use defualt */
    int32_t                     x_offset;
    bool                        use_double_eye;
    bool                        speckle_is_16bit;       /*< 8bit:row8 , 16bit:row10 */
}tsmHW3DParam;



typedef struct 
{    
    float   faceDetectThres;
    float   faceNirDetectThres;
    float   faceMatchThres;
    float   living3DThres;         /* 3d */
    float   livingNirThres;        /* 2d */
    float   livingVisNcThres;      /* 1d */
    float   livingVisThres;        /* 1d */
    float   maleThres;             /* gender */
    float   headPoseThresX;         /* head pose */
    float   headPoseThresY;         /* head pose */
}tsmFaceProcessParam;

/* AMR match */
typedef struct
{
	int			feat_len;  /* feature vector size */
	int 		pool_num;  /* number of feature vector */
	float		threshold;
	int16_t *	feat;      /* feature buffer */
	int16_t	* 	pool;      /* the feature pool*/
	/* search */
	int 		max_valid_num;
	int			max_div2_search;
	/* calculate score */
	int 		Qfeat;
}tsmMatchParam;

/**
 * @brief convert face box coordinate for live detection 
 *          !!return for use default paramter!!
 * @param vis_box : input , current visible light detection results
 * @param vis_box : input , current ir detection results
 * @param live_det_box : inout , box for live detection , has default value
 * @param extend_scale : inout , scale for box extension , has default value
 * @param extend : inout , extend mothod
 */ 
typedef void (*ConvertBoxFun_t)(const int img_h, int const img_w, 
                                    const TsmFaceBox * vis_box, const TsmFaceBox * nir_box, TsmFaceBox * live_det_box,
                                        float * extend_scale, TsmExtendMethod_e * extend);



typedef struct tagTsmSl3dInput {
    void *img_l; //3DE left input image
    void *img_r; //3DE right input image
    void *depth_input;  //depthMap input enable when run_mode.do_depth = 0 and depth_input vaild
} TsmSl3dInput;


#ifdef __cplusplus
}
#endif

#endif